:root {
  --primary-color: #4285f4;
  --secondary-color: #34a853;
  --danger-color: #ea4335;
  --warning-color: #fbbc05;
  --light-bg: #f8f9fa;
  --dark-text: #202124;
  --light-text: #5f6368;
  --border-color: #dadce0;
  --card-shadow: 0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);
  --modal-overlay: rgba(0, 0, 0, 0.5);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Roboto', 'Noto Sans SC', sans-serif;
  font-size: 14px;
  color: var(--dark-text);
  width: 500px;
  min-height: 400px;
  background-color: #fff;
}

.container {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
}

.app-header h1 {
  font-size: 18px;
  font-weight: 500;
}

.toggle-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  font-size: 12px;
}

.toggle-btn.active {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

.tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
}

.tab-btn {
  flex: 1;
  padding: 12px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  transition: background-color 0.2s;
}

.tab-btn.active {
  color: var(--primary-color);
  border-bottom: 2px solid var(--primary-color);
}

.tab-btn:hover {
  background-color: var(--light-bg);
}

.tab-content {
  flex: 1;
  overflow-y: auto;
  max-height: 400px;
}

.tab-panel {
  display: none;
  padding: 16px;
}

.tab-panel.active {
  display: block;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.panel-header h2 {
  font-size: 16px;
  font-weight: 500;
}

.action-buttons {
  display: flex;
  gap: 8px;
}

.btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.2s;
}

.btn.primary {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

.btn.secondary {
  background: #fff;
  color: var(--primary-color);
  border-color: var(--primary-color);
}

.btn.danger {
  background: var(--danger-color);
  color: white;
  border-color: var(--danger-color);
}

.btn:hover {
  opacity: 0.9;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.groups-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.group-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: var(--card-shadow);
  cursor: pointer;
  transition: all 0.2s;
}

.group-card:hover {
  border-color: var(--primary-color);
}

.group-card.selected {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px var(--primary-color);
}

.group-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.group-color {
  width: 20px;
  height: 20px;
  border-radius: 4px;
}

.group-name {
  font-weight: 500;
}

.group-keywords {
  color: var(--light-text);
  font-size: 12px;
}

.group-actions {
  display: flex;
  gap: 8px;
}

.icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--light-text);
  padding: 4px;
  border-radius: 4px;
}

.icon-btn:hover {
  background: var(--light-bg);
}

.search-box {
  position: relative;
  margin-bottom: 16px;
}

.search-box input {
  width: 100%;
  padding: 10px 36px 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 14px;
}

.search-box .material-icons {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--light-text);
}

.filter-row {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
  align-items: center;
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-group label {
  font-size: 12px;
  color: var(--light-text);
  white-space: nowrap;
}

.filter-group select {
  padding: 6px 8px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 12px;
  background: white;
}

.keywords-stats {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
  padding: 12px;
  background: var(--light-bg);
  border-radius: 4px;
  font-size: 12px;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-value {
  font-weight: bold;
  font-size: 16px;
  color: var(--primary-color);
}

.stat-label {
  color: var(--light-text);
  margin-top: 2px;
}

.keywords-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.keyword-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
}

.keyword-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.keyword-text {
  font-weight: 500;
}

.keyword-group {
  font-size: 12px;
  color: var(--light-text);
}

.keyword-tip {
  font-size: 12px;
  color: var(--light-text);
  font-style: italic;
}

.settings-section {
  margin-bottom: 24px;
}

.settings-section h3 {
  font-size: 14px;
  margin-bottom: 12px;
  font-weight: 500;
}

.setting-item {
  margin-bottom: 16px;
}

.setting-item label {
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
}

.setting-item input[type="number"],
.setting-item input[type="text"],
.setting-item select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
}

.setting-item input[type="checkbox"] {
  margin-right: 8px;
}

.setting-description {
  font-size: 12px;
  color: var(--light-text);
  margin-top: 4px;
}

.storage-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.storage-bar {
  flex: 1;
  height: 8px;
  background: var(--light-bg);
  border-radius: 4px;
  overflow: hidden;
}

.storage-used {
  height: 100%;
  background: var(--primary-color);
  border-radius: 4px;
  width: 0%;
  transition: width 0.3s;
}

.setting-actions {
  display: flex;
  gap: 8px;
}

.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--modal-overlay);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: white;
  border-radius: 8px;
  width: 400px;
  max-width: 90%;
  max-height: 90vh; /* 限制整体最大高度 */
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0; /* 防止头部被压缩 */
}

.modal-header h3 {
  font-size: 16px;
  font-weight: 500;
}

.close-btn {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--light-text);
}

.modal-body {
  padding: 16px;
  max-height: 350px; /* 限制内容区域高度 */
  overflow-y: auto;  /* 添加垂直滚动条 */
  flex: 1; /* 填充剩余空间 */
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px;
  border-top: 1px solid var(--border-color);
  flex-shrink: 0; /* 防止底部被压缩 */
}

/* 批量添加特定样式 */
#batch-keyword-modal .modal-body {
  max-height: 400px; /* 批量添加的需要更高一些 */
}

#batch-keyword-text {
  min-height: 100px;
  max-height: 150px;
  font-family: monospace;
  line-height: 1.4;
  resize: vertical;
}

#batch-keyword-tip {
  min-height: 60px;
  resize: vertical;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-family: inherit;
}

.form-group textarea {
  min-height: 80px;
  resize: vertical;
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--light-text);
}

.empty-state .material-icons {
  font-size: 48px;
  margin-bottom: 12px;
  color: var(--border-color);
}

.empty-state p {
  margin-bottom: 16px;
}

/* 批量添加预览样式 */
.batch-preview {
  margin-top: 16px;
  padding: 12px;
  background: var(--light-bg);
  border-radius: 4px;
  display: none;
}

.batch-preview h4 {
  font-size: 14px;
  margin-bottom: 8px;
  font-weight: 500;
}

.preview-list {
  max-height: 120px;
  overflow-y: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.preview-item {
  background: white;
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid var(--border-color);
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.preview-item .material-icons {
  font-size: 14px;
  color: var(--light-text);
}

/* 批量添加文本区域 */
#batch-keyword-text {
  min-height: 120px;
  font-family: monospace;
  line-height: 1.4;
}

/* 重复关键词提示 */
.duplicate-keyword {
  background: #ffebee;
  border-color: var(--danger-color);
}

.existing-keyword {
  background: #e8f5e8;
  border-color: var(--secondary-color);
}

/* 批量添加统计 */
.batch-stats {
  display: flex;
  gap: 12px;
  margin-top: 8px;
  font-size: 12px;
}

.stat-new {
  color: var(--primary-color);
}

.stat-duplicate {
  color: var(--danger-color);
}

.stat-existing {
  color: var(--secondary-color);
}

/* 滚动条样式美化 */
.modal-body::-webkit-scrollbar {
  width: 6px;
}

.modal-body::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 3px;
}

.modal-body::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 3px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

.preview-list::-webkit-scrollbar {
  height: 4px;
}

.preview-list::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 2px;
}

.preview-list::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 2px;
}


.feature-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: white;
  margin-bottom: 10px;
  border-radius: 10px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.04);
  transition: transform 0.2s, box-shadow 0.2s;
}

.feature-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.08);
}

.feature-name {
  font-size: 14px;
  flex-grow: 1;
}

.switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 20px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: .4s;
  border-radius: 20px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: #1a73e8;
}

input:checked + .slider:before {
  transform: translateX(20px);
}

.tab-item {
  padding: 5px;
  margin: 3px 0;
  background: #f5f5f5;
  border-radius: 3px;
}
.tab-item:not(:first-child) {
  margin-left: 5px; /* 设置间距 */
}
.empty {
  text-align: center;
  width: 100%;
}
.empty-content {
  margin-top: 10px;
  width: 100%;
  color: #999999;
}

.active-tabs {
  display: flex;
  flex-direction: row;  /* 水平排列 */
  justify-content: flex-start; /* 左对齐 */
  flex-wrap: wrap;
}